﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace Mimoza.CitrixPlugin
{
    public enum ServerType
    {
        Server = 0,
        PublishedApplication
    };

    public enum Resolution
    {
        Res640x480 = 0,
        Res800x600,
        Res1024x768,
        Res1280x800,
        Res1280x720,
        Res1280x768,
        ResFullScreen
    };

    public enum NumberColors
    {
        Color16 = 1,
        Color256 = 2,
        ColorThousands = 3,
        ColorMillions = 4
    };

    public enum Keyboard
    {
        OnThisComupter = 0,
        OnRemoteComputer = 1,
        WhenFullScreen = 2
    };

    public enum SoundQuality
    {
        High = 0,
        Medium = 1,
        Low = 2
    };

    public enum Microphone
    {
        Disable = 0,
        Enable,
        AskBeforeUse
    };

    public class Sound
    {
        public bool IsSoundEnabled = true;
        public SoundQuality SoundQuality = SoundQuality.Medium;
        public Microphone Microphone = Microphone.Disable;
    }

    public class StartProgram
    {
        public bool IsStartEnabled = false;
        public string ProgramPath = "";
        public string ProgramFolder = "";
    }

    public class CitrixData
    {
        public string SessionName
        {
            get { return m_sessionName; }
            set { m_sessionName = value; }
        }

        public bool IsStartOnStartup
        {
            get { return m_bIsStartOnStartup; }
            set { m_bIsStartOnStartup = value; }
        }

        public ServerType ServerType
        {
            get { return m_serverType; }
            set { m_serverType = value; }
        }

        public string PublishedAppName
        {
            get;
            set;
        }

        public string Computer
        {
            get { return m_computer; }
            set { m_computer = value; }
        }

        public string UserName
        {
            get { return m_userName; }
            set { m_userName = value; }
        }

        public string UserDomain
        {
            get { return m_userDomain; }
            set { m_userDomain = value; }
        }

        public bool UseSmartCardOnLogon
        {
            get { return m_bUseSmartCardOnLogon; }
            set { m_bUseSmartCardOnLogon = value; }
        }

        public Resolution Resolution
        {
            get { return m_resolution; }
            set { m_resolution = value; }
        }

        public NumberColors NumberColors
        {
            get { return m_numberColors; }
            set { m_numberColors = value; }
        }

        public Keyboard Keyboard
        {
            get { return m_keyboard; }
            set { m_keyboard = value; }
        }

        public Sound Sound
        {
            get { return m_sound; }
            set { m_sound = value; }
        }

        public StartProgram StartProgram
        {
            get { return m_startProgram; }
            set { m_startProgram = value; }
        }

        public string Serialize()
        {
            XmlSerializer serializer = new XmlSerializer(typeof(CitrixData));
            TextWriter text = new StringWriter();
            serializer.Serialize(text, this);
            return text.ToString();
        }

        public static CitrixData Deserialize(string data)
        {
            XmlSerializer deserializer = new XmlSerializer(typeof(CitrixData));
            using (TextReader text = new StringReader(data))
            {
                return deserializer.Deserialize(text) as CitrixData;
            }
        }
        
        string m_computer = "";
        string m_userName = "";
        string m_userDomain = "";
        string m_sessionName = "";
        bool m_bUseSmartCardOnLogon = false;
        bool m_bIsStartOnStartup = false;
        ServerType m_serverType = ServerType.Server;

        Resolution m_resolution = Resolution.Res800x600;
        NumberColors m_numberColors = NumberColors.ColorThousands;

        Sound m_sound = new Sound();
        Keyboard m_keyboard = Keyboard.WhenFullScreen;

        StartProgram m_startProgram = new StartProgram();
    }
}
